package com.github.eclipseace.mybatis.pagination;

import java.util.ArrayList;

/**
 * @author eclipseAce
 * @param <E>
 */
public class ArrayPageList<E> extends ArrayList<E> implements PageList<E> {
	private static final long serialVersionUID = 1L;

	private long total;
	private int pageIndex;
	private int pageSize;

	@Override
	public long getTotal() {
		return total;
	}

	@Override
	public int getPageIndex() {
		return pageIndex;
	}

	@Override
	public int getPageSize() {
		return pageSize;
	}

	@Override
	public int getTotalPage() {
		if (total % pageSize == 0) {
			return (int) (total / pageSize);
		} else {
			return (int) (total / pageSize) + 1;
		}
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public void setPageIndex(int index) {
		this.pageIndex = index;
	}

	public void setPageSize(int size) {
		this.pageSize = size;
	}
}
